using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

namespace SunshineFarmWord
{
    public class GridPlanteUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
    {
        [field: SerializeField, Header("选中节点")]
        private GameObject SelectNode;
        [field: SerializeField, Header("种子图标节点")]
        private Image iconImg;
        [field: SerializeField, Header("种子数字")]
        private TextMeshProUGUI gridNumber;
        [field: SerializeField, Header("数字节点")]
        private GameObject gridNumberNode;
        void Start()
        {
        }

        void Update()
        {
        }

        #region public function
        public void InitGrid(CultivateSO.CultivateItemData cultivateItemData)
        {
            gameObject.SetActive(true);
            gridNumberNode.SetActive(false);
            SetIcon(cultivateItemData.cultivateIcon);
            iconImg.color = Color.black;
        }

        public void SetIcon(Sprite icon)
        {
            iconImg.sprite = icon;
        }
        #endregion

        #region Main function
        private void ShowHideSelectNode(bool isShow)
        {
            if (SelectNode.activeSelf == isShow) return;
            SelectNode.SetActive(isShow);
        }
        #endregion

        #region Event
        // 当鼠标进入 时调用
        public void OnPointerEnter(PointerEventData eventData)
        {
            ShowHideSelectNode(true);
        }

        // 当鼠标离开 时调用
        public void OnPointerExit(PointerEventData eventData)
        {
            ShowHideSelectNode(false);
        }

        //当鼠标点击按钮
        public void OnPointerClick(PointerEventData eventData)
        {
            SystemObserverManage.Instance.CallEventNoArgs(GameObjEnumClass.EventNotifyEnum.SowSeeds);
        }
        #endregion
    }
}
